home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fsio / fsioStreamOpTable.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  10KB  |  314 lines

  1. /* 
  2.  * fsStreamOpTable.c --
  3.  *
  4.  *    The skeletons for the Stream Operation table, the Srv Open table,
  5.  *    and the routines for initializing entries in these tables.
  6.  *
  7.  * Copyright 1987 Regents of the University of California
  8.  * All rights reserved.
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  */
  17.  
  18. #ifndef lint
  19. static char rcsid[] = "$Header: /sprite/src/kernel/fsio/RCS/fsioStreamOpTable.c,v 9.4 90/10/08 15:56:44 mendel Exp $ SPRITE (Berkeley)";
  20. #endif not lint
  21.  
  22.  
  23. #include <sprite.h>
  24. #include <fs.h>
  25. #include <fsconsist.h>
  26. #include <fsio.h>
  27. #include <fsutil.h>
  28. #include <fsioFile.h>
  29.  
  30.  
  31. /*
  32.  * File type server open routine table:
  33.  *    The OpenOps consists of a single routine, 'nameOpen', which
  34.  *    is invoked on the file server after pathname resolution has
  35.  *    obtained the I/O handle for the local file that represents
  36.  *    the name of some object.  The nameOpen routine is invoked
  37.  *    depending on the type of the local file (file, directory, device, etc.)
  38.  *    The nameOpen routine does preliminary setup in anticipation
  39.  *    of opening an I/O stream to the object.
  40.  *
  41.  * THIS ARRAY INDEXED BY FILE TYPE. 
  42.  */
  43. #define    FS_NUM_FILE_TYPE    (FS_XTRA_FILE+1)
  44. Fsio_OpenOps fsio_OpenOpTable[FS_NUM_FILE_TYPE];
  45.  
  46. /*
  47.  * Stream type specific routine table.  See fsOpTable.h for an explaination
  48.  *    of the calling sequence for each routine.
  49.  *
  50.  * THIS ARRAY INDEXED BY STREAM TYPE.  Do not arbitrarily insert entries.
  51.  */
  52. Fsio_StreamTypeOps fsio_StreamOpTable[FSIO_NUM_STREAM_TYPES];
  53.  
  54.  
  55. /*
  56.  * Simple arrays are used to map between local and remote types.
  57.  */
  58. int fsio_RmtToLclType[FSIO_NUM_STREAM_TYPES] = {
  59.     FSIO_STREAM,             /* FSIO_STREAM */
  60.     FSIO_LCL_FILE_STREAM,        /* FSIO_LCL_FILE_STREAM */
  61.     FSIO_LCL_FILE_STREAM,        /* FSIO_RMT_FILE_STREAM */
  62.     FSIO_LCL_DEVICE_STREAM,    /* FSIO_LCL_DEVICE_STREAM */
  63.     FSIO_LCL_DEVICE_STREAM,    /* FSIO_RMT_DEVICE_STREAM */
  64.     FSIO_LCL_PIPE_STREAM,        /* FSIO_LCL_PIPE_STREAM */
  65.     FSIO_LCL_PIPE_STREAM,        /* FSIO_RMT_PIPE_STREAM */
  66.     FSIO_CONTROL_STREAM,        /* FSIO_CONTROL_STREAM */
  67.     FSIO_SERVER_STREAM,        /* FSIO_SERVER_STREAM */
  68.     FSIO_LCL_PSEUDO_STREAM,    /* FSIO_LCL_PSEUDO_STREAM */
  69.     FSIO_LCL_PSEUDO_STREAM,    /* FSIO_RMT_PSEUDO_STREAM */
  70.     FSIO_PFS_CONTROL_STREAM,    /* FSIO_PFS_CONTROL_STREAM */
  71.     FSIO_LCL_PSEUDO_STREAM,    /* FSIO_PFS_NAMING_STREAM */
  72.     FSIO_LCL_PFS_STREAM,        /* FSIO_LCL_PFS_STREAM */
  73.     FSIO_LCL_PFS_STREAM,        /* FSIO_RMT_PFS_STREAM */
  74.     FSIO_CONTROL_STREAM,        /* FSIO_RMT_CONTROL_STREAM */
  75.     FSIO_PASSING_STREAM,        /* FSIO_PASSING_STREAM */
  76. #ifdef INET
  77.     FSIO_RAW_IP_STREAM,        /* FSIO_RAW_IP_STREAM */
  78.     FSIO_UDP_STREAM,        /* FSIO_UDP_STREAM */
  79.     FSIO_TCP_STREAM,        /* FSIO_TCP_STREAM */
  80. #endif /* INET */
  81.  
  82. };
  83.  
  84. int fsio_LclToRmtType[FSIO_NUM_STREAM_TYPES] = {
  85.     FSIO_STREAM,             /* FSIO_STREAM */
  86.     FSIO_RMT_FILE_STREAM,        /* FSIO_LCL_FILE_STREAM */
  87.     FSIO_RMT_FILE_STREAM,        /* FSIO_RMT_FILE_STREAM */
  88.     FSIO_RMT_DEVICE_STREAM,    /* FSIO_LCL_DEVICE_STREAM */
  89.     FSIO_RMT_DEVICE_STREAM,    /* FSIO_RMT_DEVICE_STREAM */
  90.     FSIO_RMT_PIPE_STREAM,        /* FSIO_LCL_PIPE_STREAM */
  91.     FSIO_RMT_PIPE_STREAM,        /* FSIO_RMT_PIPE_STREAM */
  92.     FSIO_CONTROL_STREAM,        /* FSIO_CONTROL_STREAM */
  93.     -1,                /* FSIO_SERVER_STREAM */
  94.     FSIO_RMT_PSEUDO_STREAM,    /* FSIO_LCL_PSEUDO_STREAM */
  95.     FSIO_RMT_PSEUDO_STREAM,    /* FSIO_RMT_PSEUDO_STREAM */
  96.     FSIO_PFS_CONTROL_STREAM,    /* FSIO_PFS_CONTROL_STREAM */
  97.     FSIO_PFS_NAMING_STREAM,    /* FSIO_PFS_NAMING_STREAM */
  98.     FSIO_RMT_PFS_STREAM,        /* FSIO_LCL_PFS_STREAM */
  99.     FSIO_RMT_PFS_STREAM,        /* FSIO_RMT_PFS_STREAM */
  100.     FSIO_RMT_CONTROL_STREAM,    /* FSIO_RMT_CONTROL_STREAM */
  101.     FSIO_PASSING_STREAM,        /* FSIO_PASSING_STREAM */
  102. #ifdef INET
  103.     FSIO_RAW_IP_STREAM,        /* FSIO_RAW_IP_STREAM */
  104.     FSIO_UDP_STREAM,        /* FSIO_UDP_STREAM */
  105.     FSIO_TCP_STREAM,        /* FSIO_TCP_STREAM */
  106. #endif /* INET */
  107. };
  108.  
  109.  
  110. /*
  111.  * This array contains type-specific functions for the recovery test
  112.  * statistics syscall.
  113.  */
  114. extern    int    Fsrmt_FileRecovTestUseCount();
  115. extern    int    Fsrmt_FileRecovTestNumCacheBlocks();
  116. extern    int    Fsrmt_FileRecovTestNumDirtyCacheBlocks();
  117. Fsio_RecovTestInfo    fsio_StreamRecovTestFuncs[FSIO_NUM_STREAM_TYPES] = {
  118.     /* FSIO_STREAM */
  119.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  120.     /* FSIO_LCL_FILE_STREAM */
  121.     { Fsio_FileRecovTestUseCount, Fsio_FileRecovTestNumCacheBlocks,
  122.       Fsio_FileRecovTestNumDirtyCacheBlocks },
  123.     /* FSIO_RMT_FILE_STREAM */
  124.     { Fsrmt_FileRecovTestUseCount, Fsrmt_FileRecovTestNumCacheBlocks,
  125.       Fsrmt_FileRecovTestNumDirtyCacheBlocks},
  126.     /* FSIO_LCL_DEVICE_STREAM */
  127.     { Fsio_DeviceRecovTestUseCount, (int (*)()) NIL, (int (*)()) NIL },
  128.     /* FSIO_RMT_DEVICE_STREAM */
  129.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  130.     /* FSIO_LCL_PIPE_STREAM */
  131.     { Fsio_PipeRecovTestUseCount, (int (*)()) NIL, (int (*)()) NIL },
  132.     /* FSIO_RMT_PIPE_STREAM */
  133.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  134.     /* FSIO_CONTROL_STREAM */
  135.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  136.     /* FSIO_SERVER_STREAM */
  137.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  138.     /* FSIO_LCL_PSEUDO_STREAM */
  139.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  140.     /* FSIO_RMT_PSEUDO_STREAM */
  141.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  142.     /* FSIO_PFS_CONTROL_STREAM */
  143.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  144.     /* FSIO_PFS_NAMING_STREAM */
  145.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  146.     /* FSIO_LCL_PFS_STREAM */
  147.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  148.     /* FSIO_RMT_PFS_STREAM */
  149.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  150.     /* FSIO_RMT_CONTROL_STREAM */
  151.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  152.     /* FSIO_PASSING_STREAM */
  153.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  154. #ifdef INET
  155.     /* FSIO_RAW_IP_STREAM */
  156.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  157.     /* FSIO_UDP_STREAM */
  158.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  159.     /* FSIO_TCP_STREAM */
  160.     { (int (*)()) NIL, (int (*)()) NIL, (int (*)()) NIL },
  161. #endif /* INET */
  162. };
  163.  
  164. /*
  165.  *----------------------------------------------------------------------
  166.  *
  167.  * Fsio_InstallStreamOps --
  168.  *
  169.  *    Install the stream operation routines for a specified stream type.
  170.  *    
  171.  *    The stream operations are the main set of operations on objects.
  172.  *    These include operations for I/O, migration, recovery, and
  173.  *    garbage collection.
  174.  *
  175.  * Results:
  176.  *    None.
  177.  *
  178.  * Side effects:
  179.  *    fsio_StreamOpTable modified.
  180.  *
  181.  *----------------------------------------------------------------------
  182.  */
  183. void
  184. Fsio_InstallStreamOps(streamType, streamOpsPtr)
  185.     int        streamType;     /* Stream type to install operations for. */
  186.     Fsio_StreamTypeOps *streamOpsPtr; /* Operations for stream. */
  187. {
  188.     fsio_StreamOpTable[streamType] = *streamOpsPtr;
  189. }
  190.  
  191. /*
  192.  *----------------------------------------------------------------------
  193.  *
  194.  * Fsio_InstallSrvOpenOp --
  195.  *
  196.  *    Install file server open procedure for a specified file type.
  197.  *
  198.  *    The server open procedure is called after pathname resolution
  199.  *    has obtained the I/O handle for the local file that represents
  200.  *    the name of the object.  The server open procedure does preliminary
  201.  *    open-time setup for files of its particular type (file, directory,
  202.  *    device, pseudo-device, remote link, etc.).
  203.  *
  204.  * Results:
  205.  *    None.
  206.  *
  207.  * Side effects:
  208.  *    fsio_OpenOpTable modified.
  209.  *
  210.  *----------------------------------------------------------------------
  211.  */
  212.  
  213. void
  214. Fsio_InstallSrvOpenOp(fileType, openOpsPtr)
  215.     int        fileType;     /* File type to install operations for. */
  216.     Fsio_OpenOps  *openOpsPtr;     /* Operations for file type. */
  217.  
  218. {
  219.     fsio_OpenOpTable[fileType] = *openOpsPtr;
  220. }
  221.  
  222. /*
  223.  *----------------------------------------------------------------------
  224.  *
  225.  * Fsio_NullProc --
  226.  *
  227.  *    Null procedure for entries in Fsio_StreamTypeOps table.
  228.  *
  229.  * Results:
  230.  *    SUCCESS.
  231.  *
  232.  * Side effects:
  233.  *    None.
  234.  *
  235.  *----------------------------------------------------------------------
  236.  */
  237.  
  238. ReturnStatus
  239. Fsio_NullProc()
  240. {
  241.     return(SUCCESS);
  242. }
  243.  
  244. /*
  245.  *----------------------------------------------------------------------
  246.  *
  247.  * Fsio_NoProc --
  248.  *
  249.  *    No procedure for entries in Fsio_StreamTypeOps table. This is always
  250.  *    returns failure.
  251.  *
  252.  * Results:
  253.  *    FAILURE.
  254.  *
  255.  * Side effects:
  256.  *    None.
  257.  *
  258.  *----------------------------------------------------------------------
  259.  */
  260. ReturnStatus
  261. Fsio_NoProc()
  262. {
  263.     return(FAILURE);
  264. }
  265.  
  266. /*
  267.  *----------------------------------------------------------------------
  268.  *
  269.  *  Fsio_NullClientKill --
  270.  *
  271.  *      Minimum procedure for client kill stream operation.
  272.  *
  273.  * Results:
  274.  *    None
  275.  *
  276.  * Side effects:
  277.  *    Handle unlocked.
  278.  *
  279.  *----------------------------------------------------------------------
  280.  */
  281.  
  282. /*ARGSUSED*/
  283. void
  284. Fsio_NullClientKill(hdrPtr, clientID)
  285.     Fs_HandleHeader *hdrPtr;
  286.     int clientID;
  287. {
  288.     Fsutil_HandleUnlock(hdrPtr);
  289. }
  290.  
  291. /*
  292.  *----------------------------------------------------------------------
  293.  *
  294.  * Fsio_NoHandle --
  295.  *
  296.  *    Stub for a stream ops client verify routine that will always fail.
  297.  *
  298.  * Results:
  299.  *    A NILL FsHanldeHeader.
  300.  *
  301.  * Side effects:
  302.  *    None.
  303.  *
  304.  *----------------------------------------------------------------------
  305.  */
  306.  
  307. Fs_HandleHeader *
  308. Fsio_NoHandle()
  309. {
  310.     return((Fs_HandleHeader *)NIL);
  311. }
  312.  
  313.  
  314.